import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import viteCompression from "vite-plugin-compression";
// https://vitejs.dev/config/
export default defineConfig({
  publicPath: "/",
  outputDir: "dist",
  assetsDir: "static",
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
      "@i": path.resolve(__dirname, "./src/assets"),
    },
  },
  server: {
    // 请求代理
    proxy: {
      "/api": {
        // 这里的地址是后端数据接口的地址
        target: "http://ywapi.kfcit.com/",
        //rewrite: (path) => path.replace(/^\/admin/, ''),
        // 允许跨域
        changeOrigin: true,
      },
    },
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    viteCompression(),
  ],
});
